package com.rsk.dao.curriculum.extend;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Component;


@Component
public class RskCourseExtend {
	
	public Map<String, Object> selectCourseCategoryByPage(String categoryName){
		 // 拼接SQL语句
       StringBuilder sql = new StringBuilder("SELECT id,course_name,category_id,sort FROM rsk_course where is_del = 0");
       StringBuilder countSql = new StringBuilder("SELECT count(id) FROM rsk_course where is_del = 0 ");
       
       // 查询需要的参数，先存进Map
       StringBuilder paramSql = new StringBuilder();
       Map<String, Object> paramMap = new HashMap<String, Object>();
       if (categoryName != null && !categoryName.isEmpty()) {
    	   paramSql.append(" and category_name like :categoryName");
    	   paramMap.put("categoryName", "%" + categoryName + "%");
       }
       //排序
       StringBuilder orderSql = new StringBuilder();
       orderSql = orderSql.append(" order by sort");
       
       Map<String, Object> returnMap = new HashMap<String, Object>();
       returnMap.put("sql", sql.append(paramSql).append(orderSql));
       returnMap.put("countSQL", countSql.append(paramSql));
       returnMap.put("paramMap", paramMap);
       return returnMap;
	}
}
 